from Tkinter import *

class chooseAtom:
    "Choose the three atoms to define a plane"
    def __init__(self, master):
        frame1=Frame(master)
        frame1.pack()

        self.lab1=Label(frame1,text=\
                        'You need 3 points to define a plan,\n you could either choose the atoms of the molecule or indique the positions your self. ')
        self.lab1.pack()
        
        self.atom = []
        
        def onPress(i,self):
            self.atom[i] = not self.atom[i]  
        for i in range(10):
            self.chk = Checkbutton(frame1, text=str(i), command=(lambda i=i: onPress(i,self)) )
            #str to be replaced by the information of atoms
            self.chk.pack(side=LEFT)
            self.atom.append(0)

        frame2=Frame(master)
        frame2.pack()

        self.labpt=[0]*3
        for i in range(3):
            self.labpt[i]=Label(frame2,text='Point '+str(i))
            self.labpt[i].grid(row=1,column=i+1)

        self.labx=Label(frame2,text='x : ')
        self.labx.grid(row=2,sticky=E)

        self.laby=Label(frame2,text='y : ')
        self.laby.grid(row=3,sticky=E)

        self.labz=Label(frame2,text='z : ')
        self.labz.grid(row=4,sticky=E)


        self.enter=[0]*3
        for i in range(3):
            self.enter[i]=[0]*3
            for j in range(3):
                self.enter[i][j]=Entry(frame2)
                self.enter[i][j].grid(row=j+2,column=i+1,padx=2,pady=2)

        self.bouton=Button(frame2,text='Ok',fg='green',command=self.inp)
        self.bouton.grid(row=5,column=2,padx=5,pady=5)

    def inp(self):
        self.ent=[]
        for i in range(3):
            temp=[0]*3
            flag=0
            for j in range(3):
                if self.enter[i][j].get()!='':
                    flag=1
                    temp[j]=float(self.enter[i][j].get())
            if flag:
                self.ent.append(temp)
        print m.atom,m.ent


       

 



        


root=Tk()
m=chooseAtom(root)
root.mainloop()
print m.atom,m.ent
